package Servlet.AtencionDiaria;

import java.io.IOException;
import java.util.Collection;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.JOptionPane;

import com.huellas.bean.ReporteAtencionDiaria;
import com.huellas.negocio.GestionReporteAtencionDiaria;

/**
 * Servlet implementation class ReporteAtencionDiariaServlet
 */
@WebServlet("/ReporteAtencionDiariaServlet")
public class ReporteAtencionDiariaServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ReporteAtencionDiariaServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		this.doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String FecIni = request.getParameter("txtFechaInicio");
		String FecFin = request.getParameter("txtFechaFin");
		int CodDoc = Integer.parseInt(request.getParameter("cmbDoctor").toString());
		int CodEstadoCita =Integer.parseInt( request.getParameter("cmbEstadoCita").toString());
		
		GestionReporteAtencionDiaria gRepAte = new GestionReporteAtencionDiaria();
		
		try{
			Collection<ReporteAtencionDiaria> ListaReporte = gRepAte.MuestraReporte(FecIni, FecFin, CodDoc, CodEstadoCita);
			request.setAttribute("Reporte", ListaReporte);
			RequestDispatcher rd = request.getRequestDispatcher("Reporte_AtencionDiaria.jsp");
			rd.forward(request, response);
		}catch(Exception e){
			System.out.println(e.getMessage());
			RequestDispatcher rd = request.getRequestDispatcher("error_Veterinaria.jsp");
			rd.forward(request, response);
		}
	}

}
